package com.chen.learnknowledge.service;

import com.alibaba.fastjson.JSONObject;
import com.chen.learnknowledge.entity.Ue;
import com.chen.learnknowledge.entity.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;

import java.time.Duration;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {

       /* List<String> list = new ArrayList<>();
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张强");
        list.add("张三丰");
        list.stream().filter(s -> s.startsWith("张")).filter(s->s.length()>2).forEach(System.out::println);
        System.out.println(list.stream().count());
        list.stream().skip(2).forEach(System.out::println);
        list.stream().limit(3).forEach(System.out::println);

        Stream<String> original = Stream.of("11", "22", "33");
        Stream<Integer> integerStream = original.map(Integer::parseInt);
        integerStream.forEach(s -> System.out.println(s + 10));
        System.out.println("------------------------------");
        Stream.of(33, 22, 11, 55)
                .sorted((s1,s2)->s2-s1).forEach(System.out::println);

        System.out.println("------------------------------map");

        Ue u100=new Ue();*/

        /*List<String> collect = Stream.of(new Ue("刘德华", 58),
                new Ue("张学友", 56),
                new Ue("张学友", 56),
                new Ue("黎明", 52)).map(Ue::getName).collect(Collectors.toList());
        System.out.println("------------------------------map");
        Ue u1=new Ue("刘德华", 58);
        Ue u2=new Ue("张学友", 55);
        Ue u3=new Ue("黎明", 53);
        Ue u4=new Ue("古巨基", 50);
        Ue u5=new Ue("郭富城", 48);
        ArrayList<Ue> ueArrayList2 = new ArrayList<>();
        Ue u7=new Ue("古巨基", 57);
        Ue u8=new Ue("郭富城", 58);
        ueArrayList2.add(u7);
        ueArrayList2.add(u8);
        ArrayList<Ue> ueArrayList = new ArrayList<>();
        ueArrayList.add(u1);
        ueArrayList.add(u2);
        ueArrayList.add(u3);
        ueArrayList.add(u4);
        ueArrayList.add(u5);
        List<Ue> collect1 = ueArrayList.stream().filter(ue -> !ueArrayList2
                .stream()
                .map(Ue::getName)
                .collect(Collectors.toList())
                    .contains(ue.getName())).collect(Collectors.toList());
        System.out.println(collect1);
        System.out.println("------------------------------maptest");*/

        /*int reduce = Stream.of(4, 5, 3, 9)
                .reduce(0, (a, b) -> {
                    System.out.println("a = " + a + ", b = " + b);
                return a + b; }); // reduce: // 第一次将默认做赋值给x, 取出第一个元素赋值给y,进行操作 // 第二次,将第一次的结果赋值给x, 取出二个元素赋值给y,进行操作 // 第三次,将第二次的结果赋值给x, 取出三个元素赋值给y,进行操作 // 第四次,将第三次的结果赋值给x, 取出四个元素赋值给y,进行操作
         System.out.println("reduce = " + reduce);
         String s1="3002.emal";
         String s2="3002.fal";
         String s3= "abcd";
         String s4="ssss";
         List<Ue> list1 =new ArrayList<Ue>();
         Ue u1=new Ue();
         u1.setName(s1);
         Ue u2=new Ue();
        u2.setName(s2);
         Ue u4=new Ue();
        u4.setName(s4);
         Ue u3=new Ue();
        u3.setName(s3);

        list1.add(u1);
        list1.add(u2);
        list1.add(u3);
        list1.add(u4);



        list1.sort(Comparator.comparing(Ue::getName));
        System.out.println(list1);*/

        /*User user=new User();
        user.setId(1);
        user.setAge(18);
        user.setUserName("zhangsan");
        user.setSex("nan");
        User user2=new User();
        user2.setId(1);
        user2.setUserName("lis");
        BeanUtils.copyProperties(user,user2);
        System.out.println(user2);

        String st1="sadas2";*/
       /* Ue u1=new Ue("刘德华", 58);
        Ue u2=new Ue("张学友", 55);
        Ue u3=new Ue("黎明", 53);
        Ue u4=new Ue("古巨基", 50);
        Ue u5=new Ue("郭富城", 48);
        ArrayList<Ue> ueArrayList = new ArrayList<>();
        ueArrayList.add(u1);
        ueArrayList.add(u2);
        ueArrayList.add(u3);
        ueArrayList.add(u4);
        ueArrayList.add(u5);
        List<Map<String , Object>> list=new ArrayList<>();
        LinkedHashMap<String ,Object> stringLinkedHashMap = new LinkedHashMap<>();
        for (int i = 0; i < ueArrayList.size(); i++) {
            stringLinkedHashMap.put("name",ueArrayList.get(i).getName());
            stringLinkedHashMap.put("age",ueArrayList.get(i).getAge());
            list.add(stringLinkedHashMap);
        }
        System.out.println(list);
*/
        /*String st="a23sdsadsa";


        String s2="http:123,1321,12321:/cd/asdsadsada";
        System.out.println(s2.substring(0,s2.indexOf("cd")).concat("ssdddssssssssss"));
*/
        //LocalDateTime time = LocalDateTime.parse("2022-03-04", DateTimeFormatter.ofPattern("yy-MM-dd HH:mm:ss"));
       // LocalDateTime time2 = LocalDateTime.parse("2022-03-05", DateTimeFormatter.ofPattern("yy-MM-dd HH:mm:ss"));
        LocalTime localTime = LocalTime.now();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        LocalTime localTime2 = LocalTime.now();
        Duration du2 = Duration.between(localTime, localTime2);
        System.out.println(du2);
        System.out.println(du2.toMillis());
        System.out.println("hotfix分支已经创建");
        System.out.println("删除hof分支");

    }
}
